package com.t.codebook.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.t.codebook.mapper.CodeMapper;
import com.t.codebook.model.dto.code.CodeQueryRequest;
import com.t.codebook.model.entity.Code;
import com.t.codebook.model.vo.CodeVO;
import com.t.codebook.service.CodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;


/**
 * 代码库服务实现
 *
 */
@Service
@Slf4j
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements CodeService {

    @Resource
    private CodeMapper codeMapper;

    /**
     * 分页获取代码库封装
     *
     * @return
     */
    @Override
    public PageInfo<CodeVO> getCodeVOPage(CodeQueryRequest codeQueryRequest) {
        PageHelper.startPage(codeQueryRequest.getCurrent(), codeQueryRequest.getPageSize());
        List<CodeVO> codeVOS = codeMapper.selectCodeListByCondition(codeQueryRequest);
        return new PageInfo<CodeVO>(codeVOS);
    }

    @Override
    public CodeVO getCodeVO(Long id) {
        CodeVO resCodeVo = codeMapper.selectCodeVO(id);
        return resCodeVo;
    }

}
